﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml;
namespace TerryDong.Data
{
    public class XmlContext<T> : IDataContext<T>
    {
        XmlDocument _doc = null;
        string _filePath = string.Empty;

        private static XmlContext<T> instance = null;

        private XmlContext(string filePath)
        {
            _filePath = filePath;
            _doc = new XmlDocument();
            _doc.Load(filePath);
        }

        public static XmlContext<T> CreateInstance(string filePath)
        {

            if (instance == null)
            {
                instance = new XmlContext<T>(filePath);
            }
            else
            {
                if (instance._filePath!=filePath)
                {
                    instance = new XmlContext<T>(filePath);
                }
            }
            return instance;
        }


        #region IDataContext<T> Members

        public void AddModel(T model)
        {
            throw new NotImplementedException();
        }

        public void AddModel(T model, List<string> identityColumns)
        {
            throw new NotImplementedException();
        }

        public void DeleteModels(string whereCondition)
        {
            throw new NotImplementedException();
        }

        public System.Data.DataTable GetDataTable(string whereCondition)
        {
            throw new NotImplementedException();
        }

        public T GetModelByPrimaryKey(string primaryKey, T model)
        {
            throw new NotImplementedException();
        }

        public T GetModelByPrimaryKey(string primaryKey, T model, string[] toSelectedColumns)
        {
            throw new NotImplementedException();
        }

        public IList<T> GetModels(string[] toSelectedColumns, string whereCondition)
        {
            throw new NotImplementedException();
        }

        public IList<T> GetModels(string whereCondition)
        {
            throw new NotImplementedException();
        }

        public void Truncate()
        {
            throw new NotImplementedException();
        }

        public void UpdateModelByPrimaryKey(string primaryKey, T model, List<string> identityColumns)
        {
            throw new NotImplementedException();
        }

        public void UpdateModelByPrimaryKey(string primaryKey, T model)
        {
            throw new NotImplementedException();
        }

        public void UpdateModels(T model, string whereCondition)
        {
            throw new NotImplementedException();
        }

        public void UpdateModels(T model, string whereCondition, List<string> identityColumns)
        {
            throw new NotImplementedException();
        }

        #endregion

        #region IDataContext<T> Members


        public System.Data.DataTable GetDataTable(string whereCondition, string orderBy, int pageSize, int pageNumber)
        {
            throw new NotImplementedException();
        }

        public IList<T> GetModels(string whereCondition, string orderBy, int pageSize, int pageNumber)
        {
            throw new NotImplementedException();
        }

        #endregion
    }
}
